﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Primitives;

IConfigurationBuilder builder = new ConfigurationBuilder();
builder.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);

IConfigurationRoot configurationRoot = builder.Build();
IConfigurationSection configurationSection = configurationRoot.GetSection("Student");
// var token = configurationRoot.GetReloadToken();

ChangeToken.OnChange(() => configurationRoot.GetReloadToken(), () =>
{
    Console.WriteLine("配置发生改变了...");
    Console.WriteLine($"Code:{configurationSection["Code"]}");
    Console.WriteLine($"Name:{configurationSection["Name"]}");
});
Console.Read();